package com.ethink.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ethink.system.api.info.SystemAppInfo;
import com.ethink.system.common.entity.SystemApp;
import com.ethink.system.converter.SystemAppConverter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ethink.system.common.mapper.SystemAppMapper;
import com.ethink.system.service.SystemAppService;

import java.util.ArrayList;
import java.util.List;

/**
 * 系统APP表 Service接口实现
 *
 * @author default
 * @date 2022-09-26
 */
@Slf4j
@Service
public class SystemAppServiceImpl implements SystemAppService {

    @Autowired
    private SystemAppMapper systemAppMapper;

    @Autowired
    private SystemAppConverter systemAppConverter;

    @Override
    public List<SystemAppInfo> getSystemAppList() {
        QueryWrapper<SystemApp> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("id");
        List<SystemApp> systemAppList = systemAppMapper.selectList(queryWrapper);
        List<SystemAppInfo> list = new ArrayList<>();
        for (SystemApp systemApp : systemAppList) {
            SystemAppInfo systemAppInfo = systemAppConverter.convertFrom(systemApp);
            list.add(systemAppInfo);
        }
        return list;
    }
}
